package com.afkt.project.ui.slice;

import com.afkt.project.model.bean.MyListBean;
import com.afkt.project.ui.adapter.MyListAdapter;
import com.dev.utils.app.NotificationUtils;
import com.ohos.afkt.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.ListContainer;
import ohos.agp.window.dialog.ToastDialog;

import java.util.ArrayList;
import java.util.List;

/**
 * 通知栏监听服务的slice
 */
public class NotificationServiceSlice extends AbilitySlice {
    private ListContainer listContainer;
    private MyListAdapter mAdapter;

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        setUIContent(ResourceTable.Layout_layout_notification);
        initList();
    }

    private void initList() {
        List<MyListBean> list = initData();
        listContainer = (ListContainer) findComponentById(ResourceTable.Id_notification_list);
        mAdapter = new MyListAdapter(list, this);
        listContainer.setItemProvider(mAdapter);
        listContainer.setItemClickedListener((listContainer, component, position, l) -> {
            switch (position) {
                case 0:
//                        boolean flag = NotificationUtils.isAllowedNotifyNotice();
//                        if (flag) {
//                            new ToastDialog(getContext()).setText("通知权限已开启").show();
//                        } else {
//                            new ToastDialog(getContext()).setText("通知权限未开启").show();
//                        }
                    new ToastDialog(getContext()).setText("暂不支持").show();
                    break;
                case 1:
                    new ToastDialog(getContext()).setText("暂不支持").show();
                    break;
                case 2:
                    new ToastDialog(getContext()).setText("暂不支持").show();
                    break;
                default:
                    break;
            }
        });
    }

    private List<MyListBean> initData() {
        List<MyListBean> lists = new ArrayList<>();
        lists.add(new MyListBean("检查是否开启"));
        lists.add(new MyListBean("开始监听"));
        lists.add(new MyListBean("注销监听"));
        return lists;
    }
}
